package cn.sx.dao;

/*
 *@program:sx_emall_ssm
 *@author: sx
 *@desc: 商品分类接口
 *@Time: 2020/9/20  12:30
 */

import cn.sx.entity.Type;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface TypesDao {

    /*查询全部*/
    @Select("SELECT * FROM `types` ORDER BY num")
    public List<Type> selectList();

    @Select("select count(*) from types")
    int selectCount();
    /*根据id查询*/
    @Select("select * from types where id = #{id}")
     Type select(int id);

    /*根据用户名查询(验证)*/
    @Select("select * from types where name = #{name}")
    public Type selectByTypeName(String name);
    /*添加*/
    @Insert("insert into types(name,num)value(#{name},#{num})")
    @SelectKey(keyProperty = "id",statement = "SELECT LAST_INSERT_ID()",before = false,resultType = Integer.class)
    public boolean insert(Type types);

    /*修改*/
    @Update(" UPDATE `types`  SET `name`=#{name},`num`=#{num} WHERE id=#{id}")
    public boolean update(Type type);

    @Delete("delete from types where id=#{id}")
    int delete (int id);





}
